//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.farm.doc.dao.impl;

import com.farm.core.sql.query.DBRule;
import com.farm.core.sql.query.DataQuery;
import com.farm.core.sql.result.DataResult;
import com.farm.core.sql.utils.HibernateSQLTools;
import com.farm.doc.dao.DocdraftDaoInter;
import com.farm.doc.domain.Docdraft;
import java.math.BigInteger;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;

@Repository
public class DocdraftDaoImpl extends HibernateSQLTools<Docdraft> implements DocdraftDaoInter {
    @Resource(
        name = "sessionFactory"
    )
    private SessionFactory sessionFatory;

    public DocdraftDaoImpl() {
    }

    public void deleteEntity(Docdraft docdraft) {
        Session session = this.sessionFatory.getCurrentSession();
        session.delete(docdraft);
    }

    public int getAllListNum() {
        Session session = this.sessionFatory.getCurrentSession();
        SQLQuery sqlquery = session.createSQLQuery("select count(*) from farm_code_field");
        BigInteger num = (BigInteger)sqlquery.list().get(0);
        return num.intValue();
    }

    public Docdraft getEntity(String docdraftid) {
        Session session = this.sessionFatory.getCurrentSession();
        return (Docdraft)session.get(Docdraft.class, docdraftid);
    }

    public Docdraft insertEntity(Docdraft docdraft) {
        Session session = this.sessionFatory.getCurrentSession();
        session.save(docdraft);
        return docdraft;
    }

    public void editEntity(Docdraft docdraft) {
        Session session = this.sessionFatory.getCurrentSession();
        session.update(docdraft);
    }

    public Session getSession() {
        return this.sessionFatory.getCurrentSession();
    }

    public DataResult runSqlQuery(DataQuery query) {
        try {
            return query.search(this.sessionFatory.getCurrentSession());
        } catch (Exception var3) {
            return null;
        }
    }

    public void deleteEntitys(List<DBRule> rules) {
        this.deleteSqlFromFunction(this.sessionFatory.getCurrentSession(), rules);
    }

    public List<Docdraft> selectEntitys(List<DBRule> rules) {
        return this.selectSqlFromFunction(this.sessionFatory.getCurrentSession(), rules);
    }

    public void updataEntitys(Map<String, Object> values, List<DBRule> rules) {
        this.updataSqlFromFunction(this.sessionFatory.getCurrentSession(), values, rules);
    }

    public int countEntitys(List<DBRule> rules) {
        return this.countSqlFromFunction(this.sessionFatory.getCurrentSession(), rules);
    }

    public SessionFactory getSessionFatory() {
        return this.sessionFatory;
    }

    public void setSessionFatory(SessionFactory sessionFatory) {
        this.sessionFatory = sessionFatory;
    }

    protected Class<?> getTypeClass() {
        return Docdraft.class;
    }

    protected SessionFactory getSessionFactory() {
        return this.sessionFatory;
    }
}
